<?php
    namespace Traits;
    trait Jump(){
        // 作用跳转的方法 地址 显示信息 停留时间 显示模式
        public function redirect($url,$info,$time,$flag){
            if($info=''){
                header('location:'.$url);
            }else{
                echo <<<str
                <!DOCTYPE html>
                <html lang="en">
                <head>
                    <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    <title>Document</title>
                    <style>
                        body{
                            text-align: center;
                            font-size: 18px;
                        }
                        #success,#error{
                            font-size: 36px;
                        }
                        #success{
                            color: #090;;
                        }
                        #success{
                            color: #F00;;
                        }
                    </style>
                </head>
                <body>
                    <div><span id='t'>3</span>秒以后跳转</div>
                    <div>成功</div>
                </body>
                </html> 
                <script>
                window.onload=function(){
                    var t=3;
                    setInterval(function(){
                        document.getElementById('t').innerHTML=--t;
                        if(t==0){
                            location.href='index.php';
                        }
                    },1000)
                }
                </script>              
                str;
                exit;
            }
        }
    }
?>